FROM docker.m.daocloud.io/alpine:3.20

ENV LANG="en_US.UTF-8"
ENV LANGUAGE="en_US:en"
ENV LC_ALL="en_US.UTF-8"

COPY nfsd.sh /usr/bin/nfsd
COPY .bashrc /root/.bashrc

RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.20/main" > /etc/apk/repositories && \
    echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.20/community" >> /etc/apk/repositories && \
    apk add --no-cache --update --verbose nfs-utils bash iproute2 && \
    rm -rf /var/cache/apk /tmp /sbin/halt /sbin/poweroff /sbin/reboot && \
    mkdir -p /var/lib/nfs/rpc_pipefs /var/lib/nfs/v4recovery && \
    echo "rpc_pipefs   /var/lib/nfs/rpc_pipefs   rpc_pipefs   defaults 0 0" >> /etc/fstab && \
    echo "nfsd         /proc/fs/nfsd             nfsd         defaults 0 0" >> /etc/fstab && \
    chmod +x /usr/bin/nfsd

ENTRYPOINT ["/usr/bin/nfsd"]
